/* Copyright (c) 2006 celumsolutions. All Rights Reserved. */
package com.swingolf.model;

import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.*;

/**
 * @author rtm
 * @since 14.09.11
 */
public class Player {

  private Long id;

  @NotNull @Size(min = 3) @NotEmpty
  private String name;

  @NotNull @Min(0)
  private Integer score;
  private Long imageId;
  private Team team;
  private Level level;
  private Tournament tournament;

  public Player() {
  }

  public Player(String name, Integer score, Long imageId) {
    this(-1l, name, score, imageId);
  }

  public Player(Long id, String name, Integer score) {
    this.id = id;
    this.name = name;
    this.score = score;
  }

  public Player(long id, String name, int score, Long imageId) {
    this(id, name, score);
    this.imageId = imageId;
  }

  public Player(String name, int score) {
    this(-1, name, score, null);
  }

  public Player(long id, String name, int score, Long imageId, Team team) {
    this(id, name, score, imageId);
    this.team = team;
  }

  public Player(long id, String name, int score, Long imageId, Team team, Level level) {
    this(id, name, score, imageId, team);
    this.level = level;
  }

  public Player(long id, String name, int score, Long imageId, Team team, Level level, Tournament tournament) {
    this(id, name, score, imageId, team, level);
    this.tournament = tournament;
  }

  public Team getTeam() {
    return team;
  }

  public void setTeam(Team team) {
    this.team = team;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public Long getId() {
    return id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Integer getScore() {
    return score;
  }

  public void setScore(Integer score) {
    this.score = score;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Player player = (Player) o;

    if (id != null ? !id.equals(player.id) : player.id != null) return false;

    return true;
  }

  @Override
  public int hashCode() {
    return id != null ? id.hashCode() : 0;
  }

  public Long getImageId() {
    return imageId;
  }

  public void setImageId(Long imageId) {
    this.imageId = imageId;
  }

  public Level getLevel() {
    return level;
  }

  public void setLevel(Level level) {
    this.level = level;
  }

  public Tournament getTournament() {
    return tournament;
  }

  public void setTournament(Tournament tournament) {
    this.tournament = tournament;
  }
}


